/* See LICENSE for copyright and terms of use */

import org.as2lib.test.unit.TestCase;
import org.evtmng.events.*;
import org.evtmng.tween.*;

/**
 * @author Tay Ray Chuan
 */

class org.evtmng.test.unit.TweenTest extends TestCase implements IEndListener {
	private static var START:Number = 0;
	private static var END:Number = 100;
	private static var RUNS:Number = END-START+1;

	private var m_count:Number;

	public function testTween():Void {
		m_count = START;

		var twnmgr:TweenManager = TweenManager.instance();
		var th:TweenHolder = twnmgr.tweenObjectPropertyEaserBeginChangeStartEnd(
			this, "incrementRuns", null, null, null,
			START, END);
		TweenListenerBroadcaster.instance().addListenerForTween(this, th.tween());
		twnmgr.timelineManager().setTimeInterval(10);
		twnmgr.run();

		pause();
	}

	private function set incrementRuns(val:Object):Void {
		m_count++;
	}

	public function onTweenEnd(e:TweenEventInfo):Void {
		resume();

		assertEqualsWithMessage("number of runs", m_count, RUNS);
	}
}